<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>合作伙伴维护</title>
    <link rel="stylesheet" type="text/css" href="/themes/default/easyui.css" id="swicth-style">
    <link rel="stylesheet" type="text/css" href="/css/icon.css">
    <link rel="stylesheet" type="text/css" href="/css/common.css">
    <link rel="stylesheet" type="text/css" href="/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="/themes/color.css">
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/js/jquery.cookie.js"></script>
    <script type="text/javascript" src="/js/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/js/common.js"></script>
</head>

<body class="easyui-layout" style="padding:5px">
<fieldset>
    <legend>信息查询</legend>
    <form id="ffSearch" method="post">
        <div id="searchBar">
            <table cellspacing="0" cellpadding="0">
                <tr>
                    <th>统一社会信用代码：</th>
                    <td style="width:120px"><input  id="searchType" class="textbox" name="type" value="2" type="hidden"/>
                        <input name="socialCode" class="easyui-textbox" type="text" style="width:100px">
                    </td>
                    <th>公司名称：</th>
                    <td style="width:120px">
                        <input name="name" class="easyui-textbox" type="text" style="width:100px">
                    </td>
                    <th>公司地址：</th>
                    <td style="width:120px">
                        <input name="address" class="easyui-textbox" type="text" style="width:100px">
                    </td>
                    <!--<th>公司类型：</th>
                    <td style="width:120px">
                        <select id="typeSelect" name="type" class="easyui-combobox" data-options="onSelect: function(rec){onSearch()}" style="width:100px">
                            <option value="-1">全部</option>
                            &lt;!&ndash;<option value="0">平台公司</option>&ndash;&gt;
                            <option value="1">代理商</option>
                            <option value="2">合作伙伴</option>
                        </select>
                    </td>-->
                    <td colspan="2">
                        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="onSearch()">查询</a>&nbsp;&nbsp;
                        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-clear'" onclick="onClear()">重置</a>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</fieldset>

<table id="dg"> </table>

<div id="addOrEdit" class="easyui-window" title="添加合作伙伴" data-options="closed:true,iconCls:'icon-save',footer:'#ft'" style="width:600px;height:600px;padding:10px;">
    <form id="ff" method="post">
        <table class="table-blue">
            <tr>
                <th>公司类型：</th>
                <td><input id = "addType" name="type"  value="2" type="hidden"/>
                    <input disabled="true" id="addTypeName" class="textbox" value="合作伙伴" data-options="required:true, validType:'maxLength[50]'"/>
                </td>
            </tr>
            <tr>
                <th>公司名称：</th>
                <td><input type="hidden" name="id"/><input class="easyui-validatebox textbox" type="text" name="name" data-options="required:true, validType:'maxLength[50]'"/>
                </td>
            </tr>
            <tr>
                <th>统一社会信用代码：</th>
                <td><input type="hidden" name="leader"/><input class="easyui-validatebox textbox" type="text" name="socialCode" data-options="required:true, validType:'maxLength[18]'"/>
                </td>
            </tr>
            <tr>
                <th>公司地址：</th>
                <td><input class="easyui-validatebox textbox" type="text" name="address" data-options="required:true, validType:'maxLength[18]'"/>
                </td>
            </tr>
            <tr>
                <th>负责人：</th>
                <td><input class="easyui-validatebox textbox" type="text" name="leaderName" data-options="required:true, validType:'maxLength[30]'"/></td>
            </tr>
            <tr>
                <th>手机号：</th>
                <td><input class="easyui-validatebox textbox" type="text" name="mobile" data-options="required:true, validType:['mobile','maxLength[11]']"/></td>
            </tr>
            <tr>
                <th>邮箱：</th>
                <td><input class="easyui-validatebox textbox" type="text" name="email" data-options="prompt:'Enter a valid email.',validType:['email','maxLength[45]']"/></td>
            </tr>
            <tr>
                <th>银行卡号：</th>
                <td><input class="easyui-validatebox textbox" type="text" name="bankCardNumber" data-options="required:true,validType:['maxLength[50]']"/></td>
            </tr>
            <tr>
                <th>支付宝账号：</th>
                <td><input class="easyui-validatebox textbox" type="text" name="alipayAccount" data-options="validType:['maxLength[19]']"/></td>
            </tr>
            <tr>
                <th>微信账号：</th>
                <td><input class="easyui-validatebox textbox" type="text" name="wechatAccount" data-options="validType:['maxLength[50]']"/></td>
            </tr>
           <!-- <tr>
                <th>营业执照：</th>
                <td><input class="easyui-validatebox textbox" type="text" name="businessLicense" data-options="validType:['maxLength[50]']"/></td>
            </tr>-->
            <tr>
                <th style="vertical-align: middle;padding-top: 10px;">合作协议：</th>
                <td class="inputTd" >
                    <input type="hidden" name="agreementPath" id="agreementPath" value=""/>
                    <input type="hidden" name="agreementName" id="agreementName" value=""/>
                    <div style="margin-bottom:20px;display:none" id="fileDivid">
                        <!--<input class="easyui-filebox" name="agreementfile" id="agreementfile" data-options="prompt:'请选择协议'" style="width:70%">-->
                        <input type="file" name="agreementfile" id="agreementfile" data-options="prompt:'请选择协议'" onchange="uploadAgreementFile(this)"/>
                        <!--<input type="button" id="upload" value="上传" onclick="uploadAgreementFile()"/>-->
                    </div>
                    <div style="margin-bottom:20px;display:none" id="downDivid">

                    </div>
                </td>
            </tr>

            <!-- <tr>
                 <th>备注：</th>
                 <td><input class="easyui-validatebox textbox" name="remark" data-options="multiline:true, validType:'maxLength[60]'" style="height:60px;"/></td>
             </tr>-->
        </table>
    </form>
    <div id="ft" style="padding:5px;text-align: right;">
        <a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="submitForm()" style="width:80px">Ok</a> &nbsp;&nbsp;
        <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="closeWindow()" style="width:80px">Cancel</a>
    </div>
</div>


<div id="setProfitRule" class="easyui-window" title="收益规则设置" data-options="closed:true,iconCls:'icon-save',footer:'#ruleft'"
     style="width:400px;height:300px;padding:10px;">
    <div id="ruleDL">
        <form  id="ruleFF">
            <table class="table-blue">
                <tr>
                    <th>合作伙伴收益占比：</th>
                    <td>
                        <input id = "ruleId" name="id"  type="hidden" >
                        <input id = "partnerId" name="partnerId"  type="hidden">
                        <input id = "profitRule" name = "profitRule" class="easyui-numberbox" type="text" ><span>%</span>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    <div id="ruleft" style="padding:5px;text-align: right;">
        <a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="submitRuleForm()"
           style="width:80px">Ok</a> &nbsp;&nbsp;
        <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)"
           onclick="closeWindow()" style="width:80px">Cancel</a>
    </div>
</div>
    <div id="bind" class="easyui-window" title="绑定角色" data-options="closed:true,iconCls:'icon-save',footer:'#ft1'" style="width:300px;height:500px;padding:10px;">
    <div id="dl"></div>
    <div id="ft1" style="padding:5px;text-align: right;">
        <a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="bindRole()" style="width:80px">Ok</a> &nbsp;&nbsp;
        <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="closeWindow()" style="width:80px">Cancel</a>
    </div>
</div>


<div id="showDetail"  class="easyui-window" style="width:70%;height:73%;padding:10px;" title="查看详情" data-options="closed:true,iconCls:'icon-save'">
    <div id="detail" >
        <table id="detail_table" class="table-blue"  style="width:98%" >
            <tr style="height:30px;">
                <th>公司名称：</th><td align="center"><span id="detail_name"></span></td><th style="width:15%">统一社会信用代码：</th><td align="center"><span id="detail_socialCode">null</span></td>
            </tr>
            <tr style="height:30px;">
                <th>公司地址：</th><td align="center"><span id="detail_address"></span></td><th>公司责任人名称：</th><td align="center"><span id="detail_leaderName">null</span></td>
            </tr>
            <tr style="height:30px;">
                <th>公司电话：</th><td align="center"><span id="detail_mobile"></span></td><th>公司邮箱：</th><td align="center"><span id="detail_email">null</span></td>
            </tr>
            <tr style="height:30px;">
                <th>银行卡号：</th><td align="center"><span id="detail_bankCardNumber"></span></td><th>支付宝账号：</th><td align="center"><span id="detail_alipayAccount">null</span></td>
            </tr>
            <tr style="height:30px;">
                <th>微信账号：</th><td align="center"><span id="detail_wechatAccount"></span></td><th>创建时间：</th><td align="center"><span id="detail_createTime">null</span></td>
            </tr>
           <!-- <tr style="height:30px;">
                <th>备注：</th><td colspan="3"><span id="detail_remark"></span></td>
            </tr>
            <tr >
                <th>营业执照：</th><td colspan="3" align="center">
                <div style="width:90%;height:340px">
                    <img alt="" src="/images/default.jpg" width="90%" id="detail_license" style="height:340px">
                </div>
            </td>
            </tr>-->
        </table>
    </div>
    <div id="detail_close" style="padding:5px;text-align: right;">
        <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="closeWindow()" style="width:80px">Close</a>
    </div>
</div>

<script type="text/javascript">
    $(function(){
        var dg = $('#dg').datagrid();
        var queryParams = $('#ffSearch').serializeObject();

        dg.datagrid({
            url:'/v1/api0/company/list',
            queryParams: queryParams,
            columns:[[
                {field:'id',checkbox:true},
                {field:'name',title:'公司名称',width:100},
                {field:'socialCode',title:'统一社会信用代码',width:100},
                {field:'leader',title:'负责人ID',width:100,hidden:"true"},
                {field:'leaderName',title:'负责人',width:100},
                {field:'mobile',title:'手机号',width:100},
                {field:'email',title:'邮箱',width:100},
                {field:'agreementName',title:'合作协议',width:100,formatter: function(value,row,index){
                if(row.agreementName!='null'&&row.agreementName!=null&&row.agreementName!='undefined'&&row.agreementPath!='null'&&row.agreementPath!=null&&row.agreementPath!='undefined'){
                    return  '<a href='+serverPath+'/GetFile?fn='+row.agreementName+'&bt=informationFile&pt='+row.agreementPath+'>'+row.agreementName+'</a>';
                    }
                }},
                {field:'createTime',title:'创建时间',width:100,formatter: formatDateTime,hidden:"true"},
                {field:'status',title:'状态',width:40,formatter: function(value,row,index){
                    switch(value) {
                        case 1: return "启用";
                        case 2: return "禁用";
                    }
                }},
                {field:'action',title:'操作',width:120,formatter: function(value,row,index){
                    if(row.status == 1){
                        return '<a href="javascript:void(0)" onclick=setStation(\''+row.id+'\')>电站维护</a> | ' +
                        '<a href="javascript:void(0)" class="easyui-linkbutton" onclick="detail(\''+row.id+'\')">查看详情</a> | ' +
                        '<a href="javascript:void(0)" class="easyui-linkbutton" onclick="setProfitRule(\''+row.id+'\')">收益规则</a> | ' +
                            '<a href="javascript:void(0)" class="easyui-linkbutton" onclick="disable(\''+row.id+'\',\''+row.leader+'\')">禁用</a> ';
                    }else{
                        return '<a href="javascript:void(0)" onclick=setStation(\''+row.id+'\')>电站维护</a> | ' +
                        '<a href="javascript:void(0)" class="easyui-linkbutton" onclick="detail(\''+row.id+'\')">查看详情</a> | ' +
                         '<a href="javascript:void(0)" class="easyui-linkbutton" onclick="setProfitRule(\''+row.id+'\')">收益规则</a> | ' +
                            '<a href="javascript:void(0)" class="easyui-linkbutton" onclick="enable(\''+row.id+'\',\''+row.leader+'\')">启用</a>   ';
                    }
                }}
            ]],
            title:'合作伙伴管理',
            pagination: true,
            iconCls: 'icon-application_view_detail',
            singleSelect: false,
            toolbar: [{
                id: 'btnAdd',
                text: '添加',
                iconCls: 'icon-add',
                handler: function () {
                    add();
                }
            }, '-', {
                id: 'btnEdit',
                text: '修改',
                iconCls: 'icon-edit',
                handler: function () {
                    edit();
                }
            },  '-', {
                id: 'btnDisable',
                text: '禁用',
                iconCls: 'icon-remove',
                handler: function () {
                    batchDisable();
                }
            }, '-', {
                id: 'btnEnable',
                text: '启用',
                iconCls: 'icon-add',
                handler: function () {
                    batchEnable();
                }
            },  '-', {
                id: 'btnReload',
                text: '刷新',
                iconCls: 'icon-reload',
                handler: function () {
                    $("#dg").datagrid("reload");
                }
            }]
        });

        var heightMargin = $("#searchBar").height() + 45;
        $('#dg').resizeDataGrid(heightMargin, 0, 0, 0);
        $(window).resize(function() {
            $('#dg').resizeDataGrid(heightMargin, 0, 0, 0);
        });
    });

    function onSearch(){
        var queryParams = $('#ffSearch').serializeObject();
        $('#dg').datagrid({
            url:'/v1/api0/company/list',
            queryParams: queryParams
        });
    }

    function onClear() {
        $('#ffSearch').form('clear');
        $('#statusSelect').combobox('setValue', '0');
         $("#searchType").val("2");//查询默认值保持合作伙伴
        onSearch();
    }

    function add() {
        $('#ff').form('clear');
        $("#addType").val("2");//类型为合作伙伴类型2，隐藏。
        $("#addTypeName").val("合作伙伴");//类型为合作伙伴，显示。
        getshowFile("","","");
        $("#ff input[name='id']").val("");
        $("#password").removeAttr('disabled');
        $('#addOrEdit').window({title:'添加公司'});
        $('#addOrEdit').window('open');
    }

    function edit() {
        $('#ff').form('clear');
        $("#addType").val("2");//类型为合作伙伴类型2，隐藏。
        $("#addTypeName").val("合作伙伴");//类型为合作伙伴，显示。
        var row = $('#dg').datagrid('getSelected');
        if (!row){
            top.window.showMessage("请选择公司");
            return;
        }
        getshowFile(row.agreementPath,row.agreementName,row.id);
        $('#ff').form('load',row);
        $("#ff input[name='id']").val(row.id);
        $("#password").attr('disabled', 'disabled');
        $('body').data('ff-serialize', $('#ff').serialize());
        $('#addOrEdit').window({title:'编辑公司'});
        $('#addOrEdit').window('open');
    }

    function submitForm(){
        var id = $("#ff input[name='id']").val();
        var url = id.length ? "/v1/api0/company/edit" : "/v1/api0/company/add";
        var data = $('#ff').serialize();
        if(data == $('body').data('ff-serialize')) {
            top.window.showMessage("数据没有改动");
            return;
        }
        $.ajax({
            type: "post",
            url: url,
            data: data,
            datatype: "json",
            beforeSend: function () {
                if (!$('#ff').form('validate')){
                    return false;
                }
                $('#dg').datagrid('loading');
            },
            success: function (data) {
                if(data.code == 200) {
                    $('#dg').datagrid('reload');
                    top.window.showMessage();
                    closeWindow();
                } else {
                    top.window.showMessage(data.msg);
                    $('#dg').datagrid('loaded');
                }
            },
            error: function () {
                $('#dg').datagrid('loaded');
            }
        });
    }

    function closeWindow(){
        $('#addOrEdit').window('close');
        $('#setProfitRule').window('close');
        $('#showDetail').window('close');
    }

    function batchDisable() {
        var ids = [];
        var leaders = [];
        var rows = $('#dg').datagrid('getSelections');
        if(!rows.length) {
            top.window.showMessage("请选择公司");
            return;
        }
        for (var i = 0; i < rows.length; i++) {
            ids.push(rows[i].id);
            leaders.push(rows[i].leader);
        }

        top.window.$.messager.confirm('确认', '您确定要禁用选择的公司吗？', function(r){
            if (r){
                var url = "/v1/api0/company/batchDisable";
                var data = {ids: ids.join(','),leaders:leaders.join(',')};
                $.ajax(ajaxOption(url, data));
            }
        });
    }

    function batchEnable() {
        var ids = [];
        var leaders = [];
        var rows = $('#dg').datagrid('getSelections');
        if(!rows.length) {
            top.window.showMessage("请选择公司");
            return;
        }
        for (var i = 0; i < rows.length; i++) {
            ids.push(rows[i].id);
            leaders.push(rows[i].leader);
        }

        top.window.$.messager.confirm('确认', '您确定要启用选择的公司吗？', function(r){
            if (r){
                var url = "/v1/api0/company/batchEnable";
                var data = {ids: ids.join(','),leaders:leaders.join(',')};
                $.ajax(ajaxOption(url, data));
            }
        });
    }

    function disable(id,leader) {
     top.window.$.messager.confirm('确认', '您确定要禁用该公司吗？', function(r){
            if (r){
               var url = "/v1/api0/company/disable";
            var data = {id: id,leader:leader};
            $.ajax(ajaxOption(url, data));
            }
        });
    }

    function enable(id,leader) {
    top.window.$.messager.confirm('确认', '您确定要启用该公司吗？', function(r){
            if (r){
               var url = "/v1/api0/company/enable";
        var data = {id: id,leader:leader};
        $.ajax(ajaxOption(url, data));
            }
        });
    }



    function ajaxOption(url, data) {
        return {
            type: "post",
            url: url,
            data: data,
            datatype: "json",
            beforeSend: function () {
                $('#dg').datagrid('loading');
            },
            success: function (data) {
                if(data.code == 200) {
                    $('#dg').datagrid('reload');
                    top.window.showMessage();
                    closeWindow();
                } else {
                    top.window.showMessage(data.msg);
                    $('#dg').datagrid('loaded');
                }
            },
            error: function () {
                $('#dg').datagrid('loaded');
            }
        }
    }

    /*显示收益规则设置窗口*/
    function setProfitRule(partnerId){
    $('#ruleFF').form('clear');
    var url = "/v1/api0/company/getProfitRule";
    var data = {partnerId: partnerId};
    $.ajax({
                type: "post",
                url: url,
                data: data,
                datatype: "json",
                success: function (data) {
                if(data.code == 200) {
                    var rule = data.body;
                    if(rule!='null'&&rule!=null&&rule!='undefined'){
                    $('#ruleFF').form('load',rule);
                    $("#ruleFF input[name='id']").val(rule.id);
                    }
                    $("#ruleFF input[name='partnerId']").val(partnerId);
                    $('body').data('ruleFF-serialize', $('#ruleFF').serialize());
                } else {
                     top.window.showMessage(data.msg);
                }
            },
            error: function () {
                top.window.showMessage("查询收益规则失败！");
            }
    });
        $('#setProfitRule').window('open');
    }

    //提交收益规则设置
    function submitRuleForm(){
        var profitRule = $("#profitRule").val();
        if(!checkNumber(profitRule)){
            top.window.showMessage("请输入0-100以内的整数");
                return;
        }
        var url = "/v1/api0/company/saveProfitRule";
        var data = $('#ruleFF').serialize();
        if(data == $('body').data('ruleFF-serialize')) {
            top.window.showMessage("数据没有改动");
            return;
        }
        $.ajax({
            type: "post",
            url: url,
            data: data,
            datatype: "json",
            beforeSend: function () {
                if (!$('#ruleFF').form('validate')){
                    return false;
                }
            },
            success: function (data) {
                if(data.code == 200) {
                    top.window.showMessage();
                    closeWindow();
                } else {
                    top.window.showMessage(data.msg);
                }
            },
            error: function () {
                 top.window.showMessage("保存时连接失败！");
            }
        });
    }

    function setStation(partnerId){
        <!--跳转到电站页面并把合作伙伴id传过去。-->
         var url = "/view/equipment/station.html?partnerId=" + partnerId;
        addTab("电站维护",url);
    }

function getshowFile(agreementPath,agreementName,companyId){
   if(agreementPath!=""&&agreementPath!=null&&agreementPath!=undefined){
   <!--<a href="#" onclick=downLoadFile("42ad14ec-2285-4fc0-befd-39834627423a.pdf","后台管理系统.pdf")>后台管理系统.pdf</a>-->
   <!--<a href="javascript:void(0)" class="easyui-linkbutton" onclick="disable(\''+row.id+'\',\''+row.leader+'\')">禁用</a>-->
    $("#fileDivid").hide();
    $("#downDivid").show();
      var businessType="informationFile";
    $("#downDivid").html('<a href='+serverPath+'/GetFile?fn='+agreementName+'&bt='+businessType+'&pt='+agreementPath+'>'+agreementName+'</a> <input type="button" id="deletFileid" value="刪除" onclick="deletAgreementFile(\''+agreementPath+'\',\''+agreementName+'\',\''+companyId+'\')"/>');
    <!--$("#downDivid").html('');-->
    $("#agreementPath").val(agreementPath);
    $("#agreementName").val(agreementName);
    }else{
    $("#downDivid").hide();
    $("#fileDivid").show();
    $("#agreementPath").val("");
    $("#agreementName").val("");
    }
}
function isIE() {
    if (!!window.ActiveXObject || "ActiveXObject" in window){
        return true;
        }else {
        return false;
        }
}
function uploadAgreementFile(target){
 var fileSize = 0;
     if (isIE && !target.files) {
      var filePath = target.value;
      var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
      var file = fileSystem.GetFile (filePath);
      fileSize = file.Size;
    } else {
     fileSize = target.files[0].size;
     }
     var size = fileSize / 1024;
     if(size>1000){
      top.window.showMessage("附件不能大于1M!");
      target.value="";
      return;
     }
     var name=target.value;
     var fileName = name.substring(name.lastIndexOf(".")+1).toLowerCase();
     if(fileName !="doc" && fileName !="docx" && fileName !="pdf" && fileName !="txt" && fileName !="xls" && fileName !="xlsx"){
        top.window.showMessage("附件格式只支持.doc;.docx;.pdf;.txt;.xls.;xlsx!");
         target.value="";
         return ;
     }else{
 var formData = new FormData();
 formData.append("agreementfile", $('#agreementfile')[0].files[0]);
  $.ajax({
                    url: "/v1/api0/upload",
                    type: "POST",
                    data: formData,
                    /**
                    *必须false才会自动加上正确的Content-Type
                    */
                    contentType: false,
                    /**
                    * 必须false才会避开jQuery对 formdata 的默认处理
                    * XMLHttpRequest会对 formdata 进行正确的处理
                    */
                    processData: false,
                    success: function (data) {
                     if(data.code == 200) {
                       $("#upload").attr("disabled","disabled");
                       var agreementName=data.msg.split("_")[0];
                       var agreementPath=data.msg.split("_")[1];
                     $("#agreementName").val(agreementName);
                     $("#agreementPath").val(agreementPath);
                     top.window.showMessage("附件上传成功！");
                    } else {
                    $("#upload").removeAttr("disabled");
                    top.window.showMessage(data.msg);
                    }
                    },
                    error: function () {
                    $("#upload").removeAttr("disabled");
                    top.window.showMessage("附件上传失败");
                    }
                });
          }
}
function downLoadFile(agreementPath,agreementName){
          $.ajax({
                    url: "/v1/api0/downLoadFile",
                    type: "POST",
                    dataType:"json",
                    data:{"agreementPath":agreementPath,"agreementName":agreementName},
                    async:false,
                    success: function (data) {
                    if(data.code == 200) {
                     top.window.showMessage("附件下载成功！");
                    } else {
                    top.window.showMessage(data.msg);
                    }
                    },
                    error: function () {
                    top.window.showMessage("附件下载失败！");
                    }
                });
}
function deletAgreementFile(agreementPath,agreementName,companyId){
 $.ajax({
                    url: "/v1/api0/deletAgreementFile",
                    type: "POST",
                    dataType:"json",
                    data:{"agreementPath":agreementPath,"agreementName":agreementName,"companyId":companyId},
                    async:false,
                    success: function (data) {
                    if(data.code == 200) {
                    $("#downDivid").hide();
                    $("#fileDivid").show();
                     $("#agreementName").val("");
                     $("#agreementPath").val("");
                     top.window.showMessage("附件删除成功！");
                    } else {
                     $("#fileDivid").hide();
                     $("#downDivid").show();
                     $("#agreementName").val(agreementName);
                     $("#agreementPath").val(agreementPath);
                    top.window.showMessage(data.msg);
                    }
                    },
                    error: function () {
                     $("#fileDivid").hide();
                     $("#downDivid").show();
                     $("#agreementName").val(agreementName);
                     $("#agreementPath").val(agreementPath);
                    top.window.showMessage("附件删除失败！");
                    }
                });
}

function checkNumber(input) {
 　　     var re = /^[1-9]+[0-9]*]*$/ ;  //判断正整数  //判断字符串是否为数字/^[0-9]+.?[0-9]*$/
　　      if (!re.test(input)) {
 　　　　       return false;
 　      　}else{
            return true;
            }
      }

    function detail(comID){
    $.ajax({
    method:"post",
    url:'/v1/api0/company/detail',
    data:{companyID:comID},
    success:function(data){
        var company = data.body;
        $('#detail_name').text(company.name);
        $('#detail_socialCode').text(company.socialCode);
        $('#detail_address').text(company.address);
        $('#detail_leaderName').text(company.leaderName);
        $('#detail_mobile').text(company.mobile);
        $('#detail_email').text(company.email);
        $('#detail_bankCardNumber').text(company.bankCardNumber);
        $('#detail_alipayAccount').text(company.alipayAccount);
        $('#detail_wechatAccount').text(company.wechatAccount);
        <!--$('#detail_remark').text(company.remarks);-->
        $("#detail_license").attr("src",serverPath+"/GetImage?bt=staticInfoImage&fn="+company.licensePath);
        var createtime = company.createTime;
        createtime = new Date(createtime);
        var year = createtime.getFullYear()+'年';
        var month = createtime.getMonth()+1+'月';
        var date = createtime.getDate()+'日';
        $('#detail_createTime').text([year,month,date].join('-'));
    }
    });
$('#showDetail').window('open');
}

     function addTab(title, url){
            var parent$ = self.parent.$;      //找到父级DOM
            if (parent$('#tabs').tabs('exists', title)){
                parent$('#tabs').tabs('select', title);
                var currentTab = parent$('#tabs').tabs('getSelected');
                 parent$('#tabs').tabs('update',{
                    tab:currentTab,
                    options : {
                         content : '<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:100%;"></iframe>',
                         closable:true
                    }
                });
            } else {
                var content = '<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:100%;"></iframe>';
                parent$('#tabs').tabs('add',{
                    title:title,
                    content:content,   //tab中显示的内容
                    closable:true
                });
            }
    }

</script>
</body>
</html>
